<template>
	<view class="hover-btns">
		<image :src="imageUrl('gotop-btn.png')" mode="" v-if="showGoTop" @click="goTop" />
		<image :src="imageUrl('refresh-btn.png')" mode="" v-if="showRefresh" @click="refresh" />
		<view class="btn" v-if="showGoTop" @click="goTop">
			<uni-icons type="arrow-up" color="#fff" size="64rpx"></uni-icons>
		</view>
		<view class="btn" v-if="showRefresh" @click="refresh">
			<uni-icons type="refreshempty" color="#fff" size="64rpx"></uni-icons>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 返回顶部
			showGoTop: {
				type: Boolean,
				default: true
			},
			// 刷新按钮
			showRefresh: {
				type: Boolean,
				default: true
			},
		},
		data() {
			return {

			}
		},
		methods: {
			goTop() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 300
				})
			},
			refresh() {
				this.$emit('refresh')
			}
		}
	}
</script>

<style lang="scss">
	.hover-btns {
		position: fixed;
		right: 30rpx;
		bottom: 200rpx;
		z-index: 99;

		>image {
			display: block;
			width: 88rpx;
			height: 88rpx;
			margin-top: 20rpx;
		}

		.btn {
			width: 88rpx;
			height: 88rpx;
			margin-top: 20rpx;
			background: rgba(0, 0, 0, 0.5);
			border: 2rpx solid #fff;
			border-radius: 50%;
			text-align: center;
			line-height: 88rpx;
		}
	}
</style>